<!--********************************************************************
* Copyright© 2000 - 2018 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>

<head>
    <meta charset='utf-8' />
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
    <link rel='stylesheet' href='../../mapbox-gl.css' />
    <style>
        body {
            margin: 0;
            padding: 0;
        }

        #map {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
        }
    </style>
</head>

<body>
    <div id='map'></div>
    <script src="../../libs/jquery.min.js"></script>
    <script src="../../libs/coordtransform.js"></script>
    <script type="text/javascript" src="../../mapbox-gl-dev.js"></script>
    <script type="text/javascript" src="../../libs/mapv/mapv.min.js"></script>
    <script type="text/javascript" src="../../libs/proj4.js"></script>
    <script type="text/javascript" src="../../iclient9-mapboxgl.js"></script>
    <script type="text/javascript">
        var map = new mapboxgl.Map({
            container: 'map', // container id
            style: {
                "version": 8,
                "sources": {
                    "raster-tiles": {
                        "type": "raster",
                        "tiles": ['http://t0.tianditu.com/DataServer?T=vec_c&x={x}&y={y}&l={z}'],
                        "tileSize": 256
                    }
                },

                "layers": [{
                    "id": "simple-tiles",
                    "type": "raster",
                    "source": "raster-tiles",
                    "minzoom": 0,
                    "maxzoom": 22
                }]
            },
            crs: mapboxgl.CRS.EPSG4326,
            center: [106.563777, 29.578285],
        zoom: 11
        });
        map.on('load', function () {
            $.get('../../data/car.csv', function (csvstr) {
            var dataSet = mapv.csv.getDataSet(csvstr);
            for (var i = 0; i < dataSet._data.length; i++) {
                var item = dataSet._data[i];
                for (var j = 0; j < item.geometry.coordinates.length; j++) {
                    dataSet._data[i].geometry.coordinates[j] = coordtransform.bd09togcj02(item.geometry.coordinates[j][0], item.geometry.coordinates[j][1]);
                    dataSet._data[i].geometry.coordinates[j] = coordtransform.gcj02towgs84(dataSet._data[i].geometry.coordinates[j][0], dataSet._data[i].geometry.coordinates[j][1])
                }
            }
            var options = {
                strokeStyle: 'rgba(50, 50, 255, 0.8)',
                lineWidth: 0.05,
                globalCompositeOperation: 'lighter',
                draw: 'simple'
            };
            new mapboxgl.supermap.MapvLayer(map, dataSet, options);
        });

        });

    </script>

</body>

</html>
